package cn.tedu.controller;

import cn.tedu.dao.StudentDao;
import cn.tedu.entity.Student;
import cn.tedu.utils.ThUtils;
import org.thymeleaf.context.Context;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "SelectServlet",urlPatterns = "/select")
public class SelectServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String name = request.getParameter("name");
        String department = request.getParameter("department");
        String grade=request.getParameter("grade");
        String student=request.getParameter("student");
        System.out.println(name);
        System.out.println(department);
        System.out.println(grade);
        System.out.println(student);
        StudentDao dao=new StudentDao();
        Student student1=dao.findByName(name);
        Context context=new Context();
        context.setVariable("student",student1);
        ThUtils.print("select.html",context,response);

    }
}
